package com.example.managemyself.data.model;

import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;
import androidx.room.TypeConverters;

import com.example.managemyself.util.DateConverter;

import java.util.Date;

/**
 * AI消息实体类
 */
@Entity(tableName = "ai_messages",
        foreignKeys = @ForeignKey(
                entity = AIConversation.class,
                parentColumns = "id",
                childColumns = "conversationId",
                onDelete = ForeignKey.CASCADE
        ))
@TypeConverters({DateConverter.class})
public class AIMessage {
    @PrimaryKey(autoGenerate = true)
    private int id;
    
    private int conversationId;      // 对话ID
    private String role;             // 角色：user, assistant, system
    private String content;          // 消息内容
    private Date timestamp;          // 时间戳
    private boolean isError;         // 是否为错误消息
    private String metadata;         // 元数据（JSON格式）
    
    public AIMessage() {
        this.timestamp = new Date();
        this.isError = false;
    }
    
    public AIMessage(int conversationId, String role, String content) {
        this();
        this.conversationId = conversationId;
        this.role = role;
        this.content = content;
    }
    
    // Getters and Setters
    public int getId() {
        return id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public int getConversationId() {
        return conversationId;
    }
    
    public void setConversationId(int conversationId) {
        this.conversationId = conversationId;
    }
    
    public String getRole() {
        return role;
    }
    
    public void setRole(String role) {
        this.role = role;
    }
    
    public String getContent() {
        return content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }
    
    public Date getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }
    
    public boolean isError() {
        return isError;
    }
    
    public void setError(boolean error) {
        isError = error;
    }
    
    public String getMetadata() {
        return metadata;
    }
    
    public void setMetadata(String metadata) {
        this.metadata = metadata;
    }
} 